package com.cet.algorithm.数组;

/**
 * @program: algorithm
 * @description: 有效完全平方数判断
 * @author: 陈恩涛
 * @create: 2022-03-08 10:43
 **/
public class LC367 {
    public static boolean isPerfectSquare(int num) {
        int lo = 0;
        int hi = num;
        while(lo <= hi){
            int mid = (lo + hi) / 2;
            long temp = (long) mid * mid;
            if( temp == num){
                return true;
            } else if(temp > num){
                hi = mid - 1;
            } else{
                lo = mid + 1;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isPerfectSquare(2147483647));
    }
}
